# Add `ziti' user
# systemd-sysusers isn't on redhat7, possibly others? test and fall back to useradd as a last ditch
if command -v systemd-sysusers > /dev/null 2>&1; then
  echo 'u ziti - "openziti user" "/var/lib/ziti" "/usr/sbin/nologin"' | \
      systemd-sysusers --replace=/usr/lib/sysusers.d/ziti-edge-tunnel.conf -
else
  if ! getent group ziti > /dev/null 2>&1; then
    groupadd --system ziti
  fi
  if ! getent passwd ziti > /dev/null 2>&1; then
    useradd --system --home-dir=/var/lib/ziti --shell /usr/sbin/nologin --comment "openziti user" -g ziti --no-user-group ziti
  fi
fi